﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class RequestRoom
    {
        public string ID { get; set; }
        public string RequestID { get; set; }
        public string RoomID { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string RoomName { get; set; }
        public string OfficialStartTimestamp { get; set; }
        public string OfficialEndTimestamp { get; set; }
        public string Status { get; set; }
        public string Description { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public RequestRoom(DataAccessLayer.RequestRoom RequestRoom)
        {
            this.ID = RequestRoom.ID.ToString();
            this.RequestID = RequestRoom.RequestID.ToString();
            this.RoomID = RequestRoom.RoomID.ToString();
            this.RoomName = RequestRoom.sRoom.Rooms.Last().Name;
            this.EditorUserID = RequestRoom.EditorUserID.ToString();
            this.EditorUserName = RequestRoom.sUser.Users.Last().Username;
            this.OfficialStartTimestamp = RequestRoom.OfficialStartTimestamp.ToHijriSolarString();
            this.OfficialEndTimestamp = RequestRoom.OfficialEndTimestamp.ToHijriSolarString();
            switch ((RequestRoomStatus)RequestRoom.RequestRoomStatusID)
            {
                case RequestRoomStatus.Reserved:
                    this.Status = "رزرو شده";
                    break;
                case RequestRoomStatus.CurrentlyInUse:
                    this.Status = "در حال استفاده";
                    break;
                case RequestRoomStatus.Canceled:
                    this.Status = "انصراف داده شده";
                    break;
                case RequestRoomStatus.Finished:
                    this.Status = "به پایان رسیده";
                    break;
            }
            this.Description = RequestRoom.Description;
            this.Timestamp = RequestRoom.Timestamp.ToHijriSolarString();
            this.BackColor = RequestRoom.IsDeleted ? "#FF5555" : "#FFFFFF";
        }

        public static List<RequestRoom> Convert(List<DataAccessLayer.RequestRoom> RequestRooms)
        {
            return (RequestRooms.ConvertAll(new Converter<DataAccessLayer.RequestRoom, RequestRoom>(p => (new RequestRoom(p)))));
        }
    }
}
